%{
	def fieldsHandler = [:]
	if(_body) {
		_body.setProperty('fieldsHandler', fieldsHandler);
}%
		#{doBody as:'skip' /}
%{
	}
}%
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0" class="t0">
<tbody><tr><td valign="top" align="middle" width="100%" height="100%" colspan="10">
<div style="height:450px;overflow: auto;">
<table class="t1" cellspacing="0" cellpadding="0">
<thead>
<tr><td colspan="${_arg.fields.size+3}" class="title">&{_arg.object+".title"}</td></tr>
<tr height="22">
<td width="50">编号</td>
%{ _arg.fields.eachWithIndex() { row, i -> }%
<td width="${_arg.widths[i]}%">&{_arg.object+"."+row}</td>
%{}}%
<td width="10%">&{'option.title'}</td>
</tr> 
</thead>
<tbody>

%{ _caller.list.eachWithIndex() { object, k -> }%
<tr id="tr_${object.id}" class="row">
<td>${object.id}</td>
%{ _arg.fields.eachWithIndex() { row, i -> }%
<td class="${_arg.object}" id="${row}-${object.id}">
	%{ if(fieldsHandler[row]) { }%
		%{
			def handler = fieldsHandler[row];
			handler.setProperty('row', object);
		}%
		#{doBody body:handler /}
		%{
			handler.setProperty('row', null);
		}%
	%{ } else { }%
		${object[row]?.escape()?.raw()}
	%{}}%
</td>
%{ } }%
<td>
%{ if (fieldsHandler['option']) { }%
	%{
		def handler = fieldsHandler['option'];
		handler.setProperty('row', object);
	}%
	#{doBody body:handler /}
	%{
		handler.setProperty('row', null);
	}%
%{ } else { }%
<a href="javascript:void(0);" class="option_delete" url="@@{delete(object.id)}">删除</a>
%{ } }%
</td>
</tr>
%{ } }%
#{list 0..14-_caller.list.size(),as:"i"}
<tr id="tr0" class="row">
<td>&nbsp;</td>
%{ _arg.fields.eachWithIndex() { row, i -> }%
<td>&nbsp;</td>
%{ } }%
<td>&nbsp;</td>
</tr>
#{/list}
</tbody>
</table>
</div>
</td></tr></tbody></table>

<form action="@@{save()}">
<div id="toolbar">
%{ _arg.columns.each() { }%
<span>&{_arg.object + "." + it}:<input type="text" class="txt01" name="${_arg.object}.${it}" value=""/></span>
%{ } }%
<span><input type="submit" class="btn01" value="保存"/></span>
</div>
</form>
<script src="@@{'/public/javascripts/jquery.editinplace.packed.js'}"></script>
<script>
$(function(){
$(".${_arg.object}").editInPlace({
	callback: function(el, n, o) {
		if(el==""){return true;}
	    var m = /([a-z]+)-(\d+)/.exec(el), data = {}
	    data['${_arg.object}.id'] = m[2]
	    data['${_arg.object}.' + m[1]] = n
	    $.ajax({
	    	url: '@{save()}',
	        type: 'POST',
	        data: data,
	        success: function(data) {$('#' + el).html(n)},
	        error: function() {$('#' + el).html(o)}
	     })
		return true
	}
});
});
</script>